import { Line } from "../models/line";

export default async function linemodule(app) {
  app.get("list", (req, res) => {
    return res.createPagination(Line);
  });
  app.post("add", async (req, res) => {
    const line = new Line();
    Object.assign(line, req.body);
    await line.save();
    return line;
  });
  app.post("delete", async (req) => {
    await Line.deleteOne({ _id: req.body.id });
    return null;
  });
  app.post("update", async (req) => {
    const { id, ...body } = req.body;
    await Line.updateOne({ _id: id }, body);
    return null;
  });
}

export const autoPrefix = "/line/";
